<?php

namespace app\admin\model;

use think\Model;


class Order extends Model
{

    

    

    // 表名
    protected $name = 'order';
    
    // 自动写入时间戳字段
    protected $autoWriteTimestamp = false;

    // 定义时间戳字段名
    protected $createTime = false;
    protected $updateTime = false;
    protected $deleteTime = false;

    // 追加属性
    protected $append = [
        'create_time_text',
        'pay_time_text',
        'update_time_text',
        'del_time_text'
    ];
    

    
     public function orderTypeList()
    {
        return ['1' => ('购买商品'), '2' => '余额充值（粮币）', '3' => __('购买vip ')];
    }

    public function payTypeList()
    {
        return ['1' => ('微信小程序'), '2' => '余额（粮币）', '3' => __('微信app支付')];
    }

    public function statusList()
    {
        return ["已创建","已支付","已接单","定稿中","已完成","已取消"];
    }

    public function isevalList()
    {
        return ['0' => __('申请中'), '1' => __('已处理'), '2' => __('处理失败'), '3' => __('申请退单中'), '4' => __('申请退单通过'), '5' => __('拒绝申请退单')];
    }
      public function refStatusFb()
    {
        return ['0' => __('未评价'), '1' => __('已评价')];
    }
 
    public function refStatusFbList()
    {
        return ['0' => __('无'), '1' => __('有')];
    }

    
    public function resStatusList()
    {
        return ['0' => __('无'), '1' => __('有')];
    }

    public function isAbnormalList()
    {
        return ['0' => __('无'), '1' => '未按时上传稿件',"2"=>"截稿时间内未完成订单"];
    }




    public function getCreateTimeTextAttr($value, $data)
    {
        $value = $value ? $value : (isset($data['create_time']) ? $data['create_time'] : '');
        return is_numeric($value) ? date("Y-m-d H:i:s", $value) : $value;
    }


    public function getPayTimeTextAttr($value, $data)
    {
        $value = $value ? $value : (isset($data['pay_time']) ? $data['pay_time'] : '');
        return is_numeric($value) ? date("Y-m-d H:i:s", $value) : $value;
    }


    public function getUpdateTimeTextAttr($value, $data)
    {
        $value = $value ? $value : (isset($data['update_time']) ? $data['update_time'] : '');
        return is_numeric($value) ? date("Y-m-d H:i:s", $value) : $value;
    }


    public function getDelTimeTextAttr($value, $data)
    {
        $value = $value ? $value : (isset($data['del_time']) ? $data['del_time'] : '');
        return is_numeric($value) ? date("Y-m-d H:i:s", $value) : $value;
    }

    protected function setCreateTimeAttr($value)
    {
        return $value === '' ? null : ($value && !is_numeric($value) ? strtotime($value) : $value);
    }

    protected function setPayTimeAttr($value)
    {
        return $value === '' ? null : ($value && !is_numeric($value) ? strtotime($value) : $value);
    }

    protected function setUpdateTimeAttr($value)
    {
        return $value === '' ? null : ($value && !is_numeric($value) ? strtotime($value) : $value);
    }

    protected function setDelTimeAttr($value)
    {
        return $value === '' ? null : ($value && !is_numeric($value) ? strtotime($value) : $value);
    }


}
